﻿using UnityEngine;
using static EColor;

[RequireComponent(typeof(SpriteRenderer))]
public class SpriteController : ActionController
{
    private SpriteRenderer m_spriteRenderer;

    protected override void OnStart()
    {
        m_spriteRenderer = GetComponent<SpriteRenderer>();
        eventSystem.ColorChange += OnColorChange;
    }

    private void FixedUpdate()
    {
        if (player.Direction_Face != 0)
            transform.localScale = new Vector3(player.Direction_Face, 1, 1);
    }

    private void OnColorChange(EColor eColor)
    {
        switch (eColor)
        {
            case Blue:
                m_spriteRenderer.color = Color.white;
                break;
            case Green:
                m_spriteRenderer.color = Color.yellow;
                break;
        }
    }
}
